<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" placeholder="输入数字1" id="tex1">
    <span>~</span>
    <input type="text" placeholder="输入数字2" id="tex2">
    <input type="button" value="个数" id="btn">
    <div id="box"></div>
</body>
<script>
    function comble(n1, n2) {
        // var c = '';
        var k = 0;//计数器
        //对输入的数值进行大小值的判定；
        var a = n1 > n2 ? n1 : n2;
        var b = n1 > n2 ? n2 : n1;
        for (var i = b; i <= a && i >= b; i++) {
            for (var j = b; j <= a && j >= b; j++) {
                if (j % 2 != 0 && i != j) {
                    // c = i + '' + j;
                    k++;
                }
            }

        }
        return k;
    }
    var btn = document.getElementById('btn');
    btn.onclick = function () {
        var tex1 = document.getElementById('tex1').value * 1;
        var tex2 = document.getElementById('tex2').value * 1;
        var box = document.getElementById('box');
        var sum = comble(tex1, tex2);
        console.log(sum);
        box.innerHTML = '个数为' + sum;
    }


</script>

</html>